function Points = getControlPoints( obj )

%Retrieve data (coordinates) from all control points and store them as
%a matrix with 2 columns (X, Y).

% This file is part of CISNE.
%
%     CISNE is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     any later version.
%
%     CISNE is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
%
%     You should have received a copy of the GNU General Public License
%     along with CISNE.  If not, see <http://www.gnu.org/licenses/>.

% Copyright 2011. Jose Maria Garcia-Valdecasas Bernal

parent=[];
root=obj.m_tree.Root();
for j=0:get(root,'ChildCount')-1
    child=root.getChildAt(j);
    kind=child.getValue();
    kind=char(kind(2));
    if (strcmp(kind,'CPOINTS'))
        %Control Points located, exit loop and begin retrieving data
        parent=child;
        break
    end
end
if ~isempty(parent)
    nchildren=get(parent,'Childcount');
    if nchildren==0
        Points=[];
    else
        Points=zeros(nchildren,2);
        for j=0:nchildren-1
            child=parent.getChildAt(j);
            kind=child.getValue();
            kind=char(kind(2));
            
            data=obj.m_grids.(kind);
            Points(j+1,1)=data{1,4};
            Points(j+1,2)=data{2,4};
        end
    end
else
    Points=[];
end

end

